package common.util;

import java.util.UUID;

public  class Get32Primarykey {

	/***
	 * 随机产生32位16进制字符串
	 * @return
	 */
	public static String getRandom32PK(){
		return UUID.randomUUID().toString().replaceAll("-", "");
	} 
	
	/***
	 * 随机产生32位16进制字符串，以时间开头
	 * @return
	 */
	public static String getRandom32BeginTimePK(){
		String timeStr = DateTime.currentDateTime("yyyyMMddHHmmssSSS");
		String random32 = getRandom32PK();
		return timeStr+random32.substring(17,random32.length());
	}
	
	/***
	 * 随机产生32位16进制字符串，以时间结尾
	 * @return
	 */
	public static String getRandom32EndTimePK(){
		String timeStr = DateTime.currentDateTime("yyyyMMddHHmmssSSS");
		String random32 = getRandom32PK();
		return random32.substring(0,random32.length()-17)+timeStr;
	}
	
	
	public static void main(String[] args) {
		System.out.println("随机"+Get32Primarykey.getRandom32PK().length()+"位："+Get32Primarykey.getRandom32PK());
		System.out.println("随机"+Get32Primarykey.getRandom32BeginTimePK().length()+"位以时间打头："+Get32Primarykey.getRandom32BeginTimePK());
		System.out.println("随机"+Get32Primarykey.getRandom32EndTimePK().length()+"位以时间结尾："+Get32Primarykey.getRandom32EndTimePK());
	}
}

